import { Exclude } from 'class-transformer';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity('menu', { comment: '菜单' })
export class MenuEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ length: 8, comment: '菜单名称' })
  name: string;

  @Column({
    type: 'tinyint',
    default: 1,
    comment: '菜单等级：1一级；2二级；3三级',
  })
  level: number;

  @Column({ length: 255, comment: '路径' })
  path: string;

  @Column({
    length: 36,
    comment: '菜单图标，有则显示，没有不显示',
    default: '',
  })
  icon: string;

  @Column({ length: 36, comment: '上一级id', default: '' })
  parent_id: string;

  @Column({ type: 'tinyint', comment: '是否为超级管理员菜单', default: 0 })
  is_admin: number;

  @Exclude()
  @Column({ type: 'tinyint', comment: '是否被删除', default: 0 })
  is_delete: number;

  @Column({ comment: '排序，正序' })
  sort: number;

  @Column({ type: 'tinyint', comment: '是否启用', default: 1 })
  is_enable: number;

  @Exclude()
  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  create_time: Date;

  @Exclude()
  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  update_time: Date;
}
